package work;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;
import util.ConnectionUtil;

/**
 * Created by liuhaibin on 2017/6/9.
 */
public class NewTask {
    private static final String TASK_QUEUE_NAME="task_queue";

    public static void main(String[] argv)
            throws Exception {
        Connection connection  = ConnectionUtil.getConnection();
        Channel channel = connection.createChannel();

        channel.queueDeclare(TASK_QUEUE_NAME, true, false, false, null);

        String[] Arrmessage = {"hello1","hello2","hello3"};

        for (String message:Arrmessage){
            channel.basicPublish("", TASK_QUEUE_NAME,
                    MessageProperties.PERSISTENT_TEXT_PLAIN,
                    message.getBytes("UTF-8"));
            System.out.println(" [x] Sent '" + message + "'");
        }

        channel.close();
        connection.close();
    }

}
